package Tasks;

import AI.AiEntity;
import Constructions.AsteroidMiner;

public class MineAsteroids extends Task
{
	public AsteroidMiner m;
	boolean finished;
	
	public MineAsteroids(AsteroidMiner m)
	{
		this.m = m;
		stepList.add(new Movement(m.workingTile.getX(), m.workingTile.getY()));
		urgency = 1;
	}
	
	public void performTask(AiEntity e) 
	{
		if(currentStep < stepList.size() && stepList.get(currentStep).isFinished(e))
		{
			currentStep++;
			if (currentStep >= stepList.size())
				m.setActive(true);
		}
		if(currentStep < stepList.size())
		{
			stepList.get(currentStep).performTask(e);
		}
		else
		{
			if(m.isActive())
			{
				
			}
			else
				finished = true;
		}
	}

	public boolean isFinished(AiEntity e) 
	{
		if(finished)
			m.setActive(false);
		return finished;
	}
	
}
